from flask import Flask, render_template, request
import pyperclip

app = Flask(__name__)


@app.route('/')
def index():
    """
    主页
    """
    return render_template('index.html')


@app.route('/paste', methods=['POST'])
def paste():
    """
    将获取的数据写入系统剪贴板
    """
    code = request.data.decode('utf-8')
    pyperclip.copy(code)
    return 'ok'


if __name__ == '__main__':
    app.run(debug=True, host='0.0.0.0', port=5000)
